﻿using HDS.Data;
using HDS.IService.Sys;
using HDS.Model.Entity.Sys;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace HDS.Service.Sys
{
    public class SysFunService : ISysFunService
    {
        private SysDbContext db = new SysDbContext();

        public async Task Delete(int funId)
        {
            await db.SysFun.DeleteAsync(e => e.FunId == funId);
        }

        public async Task<SysFun> Get(int funId)
        {
            return await db.SysFun.GetByIdAsync(funId);
        }

        public async Task<List<SysFun>> GetList()
        {
            return await db.SysFun.AsQueryable().OrderBy(e => e.FunOrderby, SqlSugar.OrderByType.Asc).ToListAsync();
        }

        public async Task Save(SysFun sysFun)
        {
            if (sysFun.FunId == 0)
                await db.SysFun.InsertAsync(sysFun);
            else
                await db.SysFun.UpdateAsync(sysFun);
        }
    }
}
